Add Environment Documentation for Virtual Environment Including Local Core Repository#4669
Add Environment Documentation for Virtual Environment Including Local Core Repository#4669SoulofAkuma wants to merge 6 commits into
Conversation
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
| "opentelemetry-instrumentation", | ||
| "opentelemetry-distro", | ||
| "opentelemetry-test-utils", | ||
| "opentelemetry-exporter-otlp", |
|
|
||
| This will create a virtual environment in the `.venv` directory and install all the necessary dependencies. | ||
|
|
||
| #### Virtual Environment Including Local Core Repository |
There was a problem hiding this comment.
What I usually do is the following:
from contrib -> uv sync and uv sync --project ../opentelemetry-python --active --inexact. It will replace the previously git installed deps from -core by using the local path. Do you think this can help?
There was a problem hiding this comment.
Thanks for the feedback @emdneto . So that is the way to do it... Well I will remove the script and update the markdown with this, thanks.
Have you had any experience with debugging using a virtual environment like this, for instance with vscode?
Are the python files the ones in the actual clone of your repo then or are they coming from the venv directory?
There was a problem hiding this comment.
Are the python files the ones in the actual clone of your repo
This ⬆️
There was a problem hiding this comment.
@emdneto yes, using the script to generate a tool.uv.sources section would then use the the local files in my actual clone instead of installing the package from a remote. But your command seems to achieve the same. I still have to get around to actually locally testing it though (what I put into the PR so far I've tested of course, not your command yet)
There was a problem hiding this comment.
All right, I ran your commands through now and I've gotten the following results (I'm using where it's pulling opentelemetry-api from as an example)
So having the contrib and core repo cloned in two different folders and running a simple uv sync in the contrib repo (without your arguments yet), pulls opentelemetry-api from github as expected:
Using CPython 3.12.13 interpreter at: /opt/python/3.12.13/bin/python3
Creating virtual environment at: .venv
Resolved 292 packages in 33ms
Installed 224 packages in 348ms
...
+ opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
...
Running the command you mentioned uv sync --project ../opentelemetry-python --active --inexact after activating the environment source .venv/bin/activate gives me:
Resolved 88 packages in 13ms
Uninstalled 32 packages in 25ms
Installed 54 packages in 34ms
...
- opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
+ opentelemetry-api==1.42.0.dev0 (from file:///home/mallert2/workspace/otel/otel-python/opentelemetry-python/opentelemetry-api)
...
This looks good and it is now pulling in opentelemetry-api locally. It also changed a bunch of other dependency versions to what is in the uv.lock file of the core repository, but I guess that should be fine.
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
@emdneto I reworked the entire PR now. It just mentions the |
Description
This PR adds documentation and a script to make it easier to setup a local workspace that contains both the core python repository as well as this one. Using the documentation provided in
CONTRIBUTING.mdand having limited knowledge ofuv, I found it challenging to troubleshoot issues that may be in the core or in the contrib repository.I have now added documentation on how to manually modify the
uvconfiguration inpyproject.tomlto resolve these dependencies locally, as well as a script that scans thepyproject.tomlfiles of both the core and the contrib repository. Specifically, the helper script detects all dependencies in the contrib'spyproject.tomlwhich are not workspace dependencies, but which can be resolved via the core repository locally.Unfortunately, to my knowledge it is not a feature in uv itself to combine two workspaces like this, hence the helper script and added documentation.
Fixes #4639
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Simply clone the core repository and the contrib one locally and then run the script referencing the two pyproject.toml files.
Finally, replace the contrib's
tool.uv.sourcessection in thepyproject.tomlwith the output of the script and runuv sync.The environment that is being created should use local file references for any dependencies that are available in the core repositroy.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
Changelogs have been updated- documentation change and helper script onlyPlease let me know if a changelog should still be added for this due to the added helper script.